package com.dayaokeji.rhythmschoolstudent.client.common.vote.adapter;

import android.support.v7.widget.AppCompatCheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dayaokeji.rhythmschoolstudent.R;
import com.dayaokeji.rhythmschoolstudent.client.common.vote.VoteDetailActivity;
import com.dayaokeji.server_api.domain.VoteItem;

/**
 * Created by Zeno on 2017/10/8.
 *
 * 投票子项adapter
 */

public class VoteItemAdapter extends BaseQuickAdapter<VoteItem,BaseViewHolder> {

    public VoteItemAdapter() {
        super(R.layout.item_vote_detail_sub_item, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, VoteItem voteItem) {
        baseViewHolder.addOnClickListener(R.id.cb_vote_sub_item);
        baseViewHolder.setText(R.id.tv_subject,voteItem.getContent());

        AppCompatCheckBox checkBox = (AppCompatCheckBox) baseViewHolder.getView(R.id.cb_vote_sub_item);
        if (VoteDetailActivity.userSelectVote.contains(voteItem)) {
            checkBox.setChecked(true);
        }else{
            checkBox.setChecked(false);
        }
    }
}
